package com.byyy.ccts.modules.api.convert;

import com.byyy.ccts.modules.api.entity.BackTemperatureVo;
import com.byyy.ccts.modules.api.entity.DeliverDetailVo;
import com.byyy.ccts.modules.api.entity.DeliveryVo;
import com.byyy.ccts.modules.cc.entity.ccts.PsZcdHz;
import com.byyy.ccts.modules.cc.entity.ccts.PsZcdMx;
import com.byyy.ccts.modules.llcx.entity.LlcxDanw;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * @projectName: TODO
 * @package: com.byyy.ccts.modules.api.convert
 * @className: PsZcdMapper
 * @description: TODO
 * @author: LYB
 * @Date: 2023-01-09 18:17
 * @updateUser: LYB
 * @updateDate: 2023-01-09 18:17
 * @updateRemark:
 * @version: v1.0
 */
@Mapper(componentModel = "spring")
public interface PsZcdConvert {

    PsZcdConvert INSTANCE = Mappers.getMapper(PsZcdConvert.class);

    /**
     * 转换为冷链系统装车单汇总信息
     * @param deliveryVo
     * @return
     */
    @Mappings({
            @Mapping(source = "loadingOrderNo", target = "zhuangcdNo"),
            @Mapping(source = "driver", target = "siji"),
            @Mapping(source = "licensePlate", target = "chepaiNo"),
            @Mapping(source = "whCode", target = "cangku"),
            @Mapping(source = "dispatchTime", target = "facTime"),
            @Mapping(source = "flag", target = "deliveryState"),
            @Mapping(source = "consignmentCode", target = "tuoyCompany"),
            @Mapping(source = "consignmentName", target = "tygs")
    })
    PsZcdHz deliveryToPsZcdHz(DeliveryVo deliveryVo);

    /**
     * 转换为装车单明细信息
     * @param deliverDetailVo
     * @return
     */
    @Mappings({
            @Mapping(source = "skuNo", target = "shangpNo"),
            @Mapping(source = "skuName", target = "chineseName"),
            @Mapping(source = "tradeName", target = "tongyName"),
            @Mapping(source = "productionBatchNo", target = "lot"),
            @Mapping(source = "productionDate", target = "shengcDate"),
            @Mapping(source = "expiringDate", target = "youxDate"),
            @Mapping(source = "pieceQty", target = "shijJs"),
            @Mapping(source = "scatteredQty", target = "shijLss"),
            @Mapping(source = "actualQty", target = "shijNum"),
            @Mapping(source = "packingQty", target = "baozNum"),
            @Mapping(source = "storageMinTemp", target = "wendMin"),
            @Mapping(source = "storageMaxTemp", target = "wendMax"),
            @Mapping(source = "boxNo", target = "liushBarcode"),
            @Mapping(source = "origBillNo", target = "danjNo"),
            @Mapping(source = "soNo", target = "soNo"),
            @Mapping(source = "customCode", target = "dwId"),
            @Mapping(source = "customerName", target = "danwName"),
            @Mapping(source = "customerAddress", target = "address"),
            @Mapping(source = "ownerCode", target = "huozId"),
            @Mapping(source = "departmentName", target = "ywbm")
    })
    PsZcdMx deliveryDetailToPsZcdMx(DeliverDetailVo deliverDetailVo);

    List<PsZcdMx> deliveryDetailToPsZcdMxList(List<DeliverDetailVo> deliverDetailVo);

    /**
     * 转换为单位信息
     * @param deliverDetailVo
     * @return
     */
    @Mappings({
            @Mapping(source = "customCode", target = "danwId"),
            @Mapping(source = "customCode", target = "danwNo"),
            @Mapping(source = "customerName", target = "danwName"),
    })
    LlcxDanw deliveryDetailToLlcxDanw(DeliverDetailVo deliverDetailVo);

    List<LlcxDanw> deliveryDetailToLlcxDanwList(List<DeliverDetailVo> deliverDetailVo);

    /**
     * 转换为回传结果
     */
    @Mappings({
            @Mapping(source = "soNo", target = "soNo"),
            @Mapping(source = "shangpNo", target = "skuNo"),
            @Mapping(source = "lot", target = "productionBatchNo"),
            @Mapping(source = "shengcDate", target = "productionDate"),
            @Mapping(source = "realname", target = "coldOperator"),
            @Mapping(source = "liushBarcode", target = "boxNo"),
            @Mapping(source = "boxNo", target = "coldBoxNo"),
            @Mapping(source = "beginTemp", target = "startTemperature"),
            @Mapping(source = "beginDate", target = "beginDate", dateFormat = "yyyy-MM-dd HH:mm:ss"),
            @Mapping(source = "endDate", target = "endDate", dateFormat = "yyyy-MM-dd HH:mm:ss"),
    })
    BackTemperatureVo psZcdMxToBackTemp(PsZcdMx psZcdMx);

    List<BackTemperatureVo> psZcdMxToBackTempList(List<PsZcdMx> psZcdMxList);
}
